package com.spring.boot.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import com.spring.boot.feign.TeacherFeign;

@RestController
@RequestMapping("/order")
public class OrderController {

	@Autowired
	private TeacherFeign teacherFeign;

	@RequestMapping("/getBody")
	public Object getBody(@RequestBody String body) {
		return teacherFeign.getBody(body);
	}
	
	/* @HystrixCommand(fallbackMethod = "hiError") */
	@RequestMapping("/getMember")
	public Object getMember(@RequestParam("name") String name) {
		System.out.println("方法getMember 线程名称:"+Thread.currentThread().getName());
		return teacherFeign.getMember(name);
	}
	
	public String hiError(@RequestParam("name") String name) {
		return "服务器繁忙,请稍后再试";
	}

	@RequestMapping("/getOrder")
	public Object getOrder() {
		System.out.println("方法getOrder 线程名称:"+Thread.currentThread().getName());
		return "我是order服务";
	}

}
